#pragma once

namespace Lead_Winder
{
	template<class T>
	struct ListNode
	{
		ListNode(const T& val = T())
			:_prev(nullptr)
			,_next(nullptr)
			,_data(val)
		{}
		ListNode<T>* _next;
		ListNode<T>* _prev;
		T _data;
	};

	template<class T>
	struct iterator
	{
		typedef ListNode<T> Node;
		Node* _node;
		T& operator*()
		{
			return _node->_data;
		}
		Node& operator++()
		{
			_node = _node->_next;
			return *this;
		}

		bool operator!=()
		{
			_node < _node->_next;
		}
	};

	template<class T>
	class list
	{
	public:
		typedef ListNode<T> Node;
		list()
			:_head(new Node)
		{
			_head->_next = _head;
			_head->_prev = _head;
		}
		
		void push_back(const T& val)
		{
			Node* newnode = new Node(val);
			Node* tail = _head->_prev;
			tail->_next = newnode;
			_head->_prev = newnode;
			newnode->_prev = tail;
			newnode->_next = _head;
		}
	private:
		Node* _head;
	};
}
